#include "cpuHc32f460.h"

void InitGPIO(port_init_t *TGPIOALL_Config, int GPIOSize)
{
	uint8_t i;
	
	PORT_DebugPortSetting(TDO_SWO, Disable);
	PORT_DebugPortSetting(TRST, Disable);
	PORT_DebugPortSetting(TDI, Disable);

	for(i = 0; i < GPIOSize; i++)
	{
        CLEAR_WATCH_DOG;  
		if(TGPIOALL_Config[i].FuncReg != GPIO_DEFAULT)
		{
			PORT_Init(TGPIOALL_Config[i].enPort,TGPIOALL_Config[i].u16Pin,&TGPIOALL_Config[i].GpioReg);
			if(TGPIOALL_Config[i].GpioReg.enPinMode == Pin_Mode_Out)	
			{
				if(TGPIOALL_Config[i].bLevel == HIGH)
				{
					PORT_SetPortData(TGPIOALL_Config[i].enPort,TGPIOALL_Config[i].u16Pin);
				}
				else if(TGPIOALL_Config[i].bLevel == LOW)
				{
					PORT_ResetPortData(TGPIOALL_Config[i].enPort,TGPIOALL_Config[i].u16Pin);
				}
				else
				{
					
				}
			}			
			if(TGPIOALL_Config[i].FuncReg != Func_Gpio)
			{
				PORT_SetFunc(TGPIOALL_Config[i].enPort,TGPIOALL_Config[i].u16Pin,(en_port_func_t)TGPIOALL_Config[i].FuncReg,Disable);
			}
		}
	}
}
